﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MusicPlayerLib.Utils;

namespace MusicPlayerLib.DataModel
{
    /// <summary>
    /// 标示专辑的实体类
    /// </summary>
    [Serializable]
    public class Album
    {
        private string id;//用来唯一标示这张专辑的字符串;
        private string title;
        private string artist;
        private string year;
        private string genre;
        private int trackNum;

        //专辑的封面地址，如果音乐文件本身包含图片则读出后保存
        //如果没有则从网络获得并且保存至本地;
        private string coverLocation;//本地缓存的专辑封面

        public Album()
        {
        }

        public Album(string title, string artist, string year, string genre, int trackNum)
        {
            this.title = title;
            this.artist = artist;
            this.year = year;
            this.genre = genre;
            this.trackNum = 0;
            this.id = MusicPlayerUtils.GetAlbumId(title, artist);
        }

        #region Property
        public string Title
        {
            get{ return title;}
            set{ title= value;}
        }

        public string Artist
        {
              get{ return artist ;}
               set { artist = value; }
        }

        public string Year
        {
            get { return year; }
            set { year= value; }
        }

        public string Gerne
        {
            get { return genre; }
            set { genre = value; }
        }

        public string CoverLocation
        {
            get
            {
                if (coverLocation == null || coverLocation.Equals(string.Empty))
                    return @"Resource\Images\default_cover.jpg";
                else
                    return coverLocation;
            }
            set { coverLocation = value; }
        }
        public string ID
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }

        public int TrackNum
        {
            get
            {
                return trackNum;
            }
            set
            {
                trackNum = value;
            }
        }

        #endregion

        
        public override bool  Equals(object obj)
        {
            return (obj as Album).ID.Equals(this.id);
        }
    }
}
